package com.lg.testFunctionalInterface;


import org.junit.Test;

class Car {
	@FunctionalInterface
	public interface Supplier<T> {
	    T get();
	    default void doSomeMoreWork1()
	    {
	        // Method body
	    }
	    
	}
	private String name = "24";
	
	private String pwd;
	
    public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPwd() {
		return pwd;
	}

	public void setPwd(String pwd) {
		this.pwd = pwd;
	}

	//Supplier是jdk1.8的接口，这里和lamda一起使用了
    public static Car create(final Supplier<Car> supplier) {
        return supplier.get();
    }
 
    public static void collide(final Car car) {
        System.out.println("Collided " + car.toString());
    }
 
    public void follow(final Car another) {
        System.out.println("Following the " + another.toString());
    }
 
    public void repair() {
        System.out.println("Repaired " + this.toString());
    }
    
    @Override
	public String toString() {
		return "Car [name=" + name + ", pwd=" + pwd + "]";
	}

	@Test
    public void  test01() {
    	Car car = Car.create(Car::new);
    	System.out.println(car);
    }
}